<?php
declare(strict_types=1);

namespace App\Controller\WebApi\v1;

use App\Controller\AbstractController;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\HttpServer\Annotation\Controller;
use App\Middleware\WebApiMiddleware;
use Hyperf\HttpServer\Annotation\Middleware;
use Service\SearchService\SearchLogService;
use Hyperf\Di\Annotation\Inject;

/**
 * 商品
 * @author huj
 * @Controller(prefix="/webapi/v1/goods")
 * @Middleware(WebApiMiddleware::class)
 */
class GoodsController extends AbstractController
{
    /**
     * 通过 `@Inject` 注解注入由 `@var` 注解声明的属性类型对象
     * @Inject()
     * @var SearchLogService
     */
    protected $searchLogService;

    /**
     * 热门搜索关键词
     * @RequestMapping(path="hot", methods="get,post")
     */
    public function hot(RequestInterface $request)
    {
        $param        = $request->inputs(['page','limit']);
        $param['mid'] = $request->getAttribute('mid');
        return $this->searchLogService->hotWords($param);
    }
}